package com.iflytek.exam.mapper;

import java.util.List;

import com.iflytek.exam.domain.QuestionExam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 试题和试卷中间Mapper接口
 *
 * @author KK
 * @date 2024-07-08
 */
@Mapper
public interface QuestionExamMapper
{
    /**
     * 查询试题和试卷中间
     *
     * @param examId 试题和试卷中间主键
     * @return 试题和试卷中间
     */
    QuestionExam selectQuestionExamById(Long examId);


    /**
     * 查询试题和试卷中间列表
     *
     * @param examId 试题和试卷中间
     * @return 试题和试卷中间集合
     */
    public List<QuestionExam> selectQuestionExamList(Long examId);


    QuestionExam selectPaperQuestionByIdAndType(QuestionExam QuestionExam);

    /**
     * 新增试题和试卷中间
     *
     * @param questionExam 试题和试卷中间
     * @return 结果
     */
    public int insertQuestionExam(QuestionExam questionExam);

    @Delete("delete from tb_question_exam where exam_id = #{examId}")
    Boolean deleteQuestionExamByExamId(@Param("examId") Long examId);

    List<QuestionExam> selectPaperQuestionByUserId(Long userId);

    List<QuestionExam> selectPaperQuestionForAll();

    @Select("SELECT DISTINCT question_id, type  FROM tb_question_exam WHERE exam_id = #{examId} AND user_id = #{userId};")
    List<QuestionExam> selectQuestionExamListByExamIdAndUserId(@Param("examId") Long examId,@Param("userId") Long userId);
}
